const app = getApp();
Page({
  data: {
    monologue: '',
  },
  onLoad: function (options) {
    this.initPage();
  },
  initPage: function () {
    //刷新用户信息
    app.getUserInfo({"openId":wx.getStorageSync('openid')});
    var userInfo = wx.getStorageSync('userInfo');
    this.setData({
      monologue: userInfo.member.monologue
    });
  },
  doSave: function () {
    wx.showLoading({
      title: '保存中。。。。',
    })
    var context = this.data.monologue;
    app.doReq(app.globalData.SERVICE.USERCENTER.MY_INNER_SAVE, {
      id: wx.getStorageSync('userInfo').member.id,
      'xgmember.monologue': context
    }, 'get', function (res) {
      if (res.data.code == 200 && res.data.type === 'SUCCESS') {
        wx.showToast({
          title: '保存成功！',
          icon: 'success',
          success: function () {
            app.getUserInfoSyn({"openId":wx.getStorageSync('openid')}).then(function (value) {
              var pages = getCurrentPages();
              var currentPage = pages[pages.length - 1];//当前页面
              var pervPagge = pages[pages.length - 2];//上个页面
              pervPagge.setData({
                reloadFlag: true,
              })
              wx.hideLoading();
              wx.navigateBack({});
            });
          }
        });
      }
    });
  },
  whenInput: function (e) {
    var context = e.detail.value;
    this.data.monologue = context;
  },
  whenFocus: function (e) {
    this.setData({
      monologue: ''
    });
  }
})